package com.itheima.afternoon;

import java.lang.reflect.Field;

public class Demo04 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException {
        Class clazz = Class.forName("com.itheima.afternoon.Student");
        Field[] fields = clazz.getFields();
        for (Field field : fields) {
            System.out.println(field);
        }
        System.out.println("--------------------------------------------------");
        Field[] declaredFields = clazz.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println(declaredField);
        }
        System.out.println("--------------------------------------------------");
        Field name = clazz.getField("name");
        System.out.println(name);
        System.out.println("--------------------------------------------------");
        Field age = clazz.getDeclaredField("age");
        System.out.println(age);
        System.out.println("--------------------------------------------------");
        Field stuId = clazz.getDeclaredField("stuId");
        System.out.println(stuId);
    }
}
